package cn.itsource.org.enu;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum ShopStateEum {

    WAIT_AUDIT(0,"待审核"),
    HAVE_AUDIT(1,"已审核"),
    REJECT(-1,"驳回"),
    PASS(2,"已激活");

    private int code;

    private String name;


    public static String getNameByCode(Integer code){
        ShopStateEum[] values = ShopStateEum.values();
        ShopStateEum stateEum = Arrays.stream(ShopStateEum.values()).filter(state -> state.getCode() == code)
                .findAny().orElse(null);
        return null == stateEum?"":stateEum.getName();
//        for (ShopStateEum state : ShopStateEum.values()) {
//            if (state.getCode() == code){
//                return state.getName();
//            }
//            return "";
//        }

    }

}
